import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:namewava/utils/jc_image_path.dart';
import 'package:namewava/utils/jc_text_style.dart';

class JcDiceResult extends StatelessWidget {
  const JcDiceResult(
      {super.key, required this.dismissEvents, required this.name});
  final Function dismissEvents;
  final String name;

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
          // margin: EdgeInsets.only(left: 30.w,right: 30.w),
          width: 336.w,
          height: 241.h,
          padding: EdgeInsets.only(
            left: 15.w,
            right: 15.w,
            top: 24.h,
          ),
          decoration: const BoxDecoration(
              image: DecorationImage(
                  image: AssetImage(JcImagePath.jcDiceResBg),
                  fit: BoxFit.fill)),
          child: Column(
            children: [_titleWidget(), _loadingWidget(), _btnWidget()],
          ),
        ),
        SizedBox(
          height: 200.h,
        )
      ],
    );
  }

  _titleWidget() {
    return Text(
      'Hey everyone， \nwelcome to NameWave！',
      textAlign: TextAlign.center,
      style: JcTextStyle.poetsenOneRegularTextStyle(24.sp, Colors.white),
    );
  }

  _loadingWidget() {
    return Container(
      margin: EdgeInsets.only(left: 50.w, right: 50.w, top: 15.h, bottom: 15.h),
      height: 50.h,
      width: double.infinity,
      alignment: Alignment.center,
      decoration: BoxDecoration(
          color: Colors.white, borderRadius: BorderRadius.circular(8.r)),
      child: Text(
        name,
        style: JcTextStyle.poetsenOneRegularTextStyle(
            18.sp, const Color(0xFF00346D)),
      ),
    );
  }

  _btnWidget() {
    return Container(
      margin: EdgeInsets.only(left: 30.w, right: 30.w),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          InkWell(
            child: Image.asset(JcImagePath.jcDiceReturn),
            onTap: () {
              dismissEvents();
            },
          ),
          InkWell(
            child: Image.asset(JcImagePath.jcDiceCopy),
            onTap: () {
              Clipboard.setData(ClipboardData(text: name));
              EasyLoading.showSuccess('Success');
            },
          )
        ],
      ),
    );
  }
}
